// 3dsKeyPlayer.h: interface for the C3dsKeyPlayer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_3DSKEYPLAYER_H__A843E9B9_B9BB_4BD1_A761_D55F07D13381__INCLUDED_)
#define AFX_3DSKEYPLAYER_H__A843E9B9_B9BB_4BD1_A761_D55F07D13381__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Vge_SceneDef.h"
#include "Vge_Read3DsFile.h"

using namespace ccgis;
typedef float Lib3dsMatrix[4][4];

struct H3dsObject {
	H3dsObject* parent;
	H3dsObject* child;
	H3dsObject* brother;
	H3dsMeshObj* meshobj;
	H3dsKeyMeshInfo* keyinfo;
	H3dsVert* normal;
	H3dsVert pos;
	float dRotAngle;
	H3dsVert rot;
	H3dsVert scl;
	Lib3dsMatrix matrix;
	H3dsObject(){
		memset(this, 0, sizeof(H3dsObject));
	}
};


class AFX_EXT_CLASS C3dsKeyPlayer  
{
public:
	C3dsKeyPlayer();
	virtual ~C3dsKeyPlayer();
	
	BOOL OpenFile(CString strPath, float fScale = 1.0f);
	void Draw(float time);
	void StartPlayer(BOOL bRepeat);

protected:
	void draw_node(H3dsObject*, float time);
	void free_node(H3dsObject*);
	void calc_node_state(H3dsObject* node, float time);
	void project_coor(H3dsScene *Scene, float fScale = 1.0f);
protected:
	float m_fbaseTime;
	CRead3DsFile* m_pReadDataIn;
	H3dsScene *m_pScene;
	CString m_strPath;
	CString m_strPathName;
	H3dsObject* m_pObjRoot;
	ENVELOPE3D m_box3d;
	Lib3dsMatrix matrix;
	BOOL m_bRepeat;
	BOOL m_bStarted;

	CMapStringToString m_textureMap;
};

#endif // !defined(AFX_3DSKEYPLAYER_H__A843E9B9_B9BB_4BD1_A761_D55F07D13381__INCLUDED_)
